Support named before/after hooks, see issue #966.