added a destruct method to flush changes to db
Moved flushing object to storage into a Database class