Fix database cleanup