Remove old code. Fix database locked exception