Moved database classes into a separate file