Merge "Refactor and improve logging." am: c3d41d5093
am: 8af8235bca

Change-Id: Id583ab11513ab86f85d1c4001cf36e74fc521753