Big fixes to database