Fix cache to handle different array sizes (fix #50)