Fix crappy hook implementation.

From #5178.