Clean up MetadataDB construction, and leaky ResultSets.