Refactored out database; initial database implementation