Fix a few bugs in CI_Hook (based on PR #2762)