Various refactorings related to hooks