Bugfix database refactor

fixes #3