Bug fixing and refactoring. Added logging to DB on update and add actions.