Add hooks

Add preSave and preUpdate hooks.