Restructured and reworked the Database classes