Speed optimizations: replace native Array.indexOf with manual for loop (helper function kff.arrayIndexOf).