Removed duplication in the database classes. Moved some files around.