modifications to cache for loops to improve performance, see http://jsperf.com/js-for-loops-cached-vs-basic - fix bug
modifications to cache for loops to improve performance, see http://jsperf.com/js-for-loops-cached-vs-basic - fix bug