Give hookFunctions a return value.

And small tweaks like variable name changes.