implement hooks

- on_check
- on_reset
fix timing of calling on_reset hook
Merge branch 'issue/17', which fixes #17