Improve NPE handling for hook script enumeration (issue-253)