Refactored remaining database helper functions