fixed (hopefully) database inconsistency by syncing after every write