Refactor database classes into package