various fixes and logging improvements