Add before and after hooks.