made logging and db state consistent