Improve logging routines