Added hook to customise clearing array externally.