smarter logging and logging related fixes