Clean up database code