Finished the first round of refactoring.
Finished second round of database refactoring. Statements are only
prepared once and finalized upon destruction.