hacking on db code, cleanup