Ensure the hook directories are flattened and compacted