added safety checks for hook handler classes, fixed #1770