Fixed an incorrect incrementation which resulted in many exceptions.