fix possible endless loop
oops, fix slowyness! (n*n units were stored in cache...)