more rigorous log writing and reading