A bit of cleaning and bug fixes
Cleaning up database.py
Finished cleaning database.py