Remove unused code.
Rename and simplify some internal methods.
Add clarifying comment.
Remove unused methods.
Unlock database if open fails.