cleaned up database and code