Refactored Database class.