Fixes #5097 Add logic to handle hooks in ncf