Replace HashMap based cache with a three dimensional array, and replace List<Integer> with int[], and simplify some code to see if there any chance for further improvement.