Got the database working along with some refactoring!