New Database Code, package setup

I rewrote the database code to be more efficient/effective, and
organized everything into initialization, primary and testing packages.