Fixed many database-related things