Tolerate invalid loop bounds by setting length to maximum

The fix looks good, loader should be tolerant. Going to merge it into my master, however I'm new to GitHub. I can only hope I'm doing it right.