db lock fix and improv