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

Change-Id: Ieb9a8e3f85f41d18056a7827997f12986ff13ca1