Loop counter should now be perfectly accurate, at the expense of memory usage.