Refactored database support