Added hooks, fixed #931