Cleanup database code