fixed db structure, cleaned up some code
housekeeping