Add ability to save to the database. Refactoring.