Fix error on installation

Refactored the creation of custom hooks upon module install. Caching of existing hooks seemed to be the problem.