database process rewritten, added more logging to find bugs on windows