Improve tracing and logging

Change-Id: I252d27aa93a93cad6abc86e772affac5c28c8cf3