Minor bugfixes and logging improvements.