Adds before and after hooks