Database class refactored