Revert "remove unused code, fix setupDatabase()"

This reverts commit ae911b9a7a99ac19b3757da923a43a9d53d4dfc9.
Revert "oo optimizations"

This reverts commit 3190a0926e4ff2d67104bbb20bc41da0ea3a9eba. (didn't actually mean to do this)