Added a new cleanup code that sets up the email hook