Minor improvements to hooks.js