Hook improvements

Fixes #2484 

See #2765. There still need to be additional improvements to the hooks.

@icewind1991 @schiesbn @karlitschek @butonic @blizzz