Improved diagnostics/logging