Cleanup, refactoring and logging

Change-Id: I3c720b05403b6080e361ea0c2fa19267e5d05ab5
Merge "Cleanup, refactoring and logging"