Minor bugfixes for log writing