Improve tracing and logging

Change-Id: I51e4dc782b6b486971eaff1da57defcedc416f67