Add support for before and after hooks.