Small improvements; logging now more robust