Reverted last commit and fixed the issue.

It was a really dumb mistake I have to admit. Also changed to normal
for-loops. This means that it can finally be used completely, however,
I'm gonna do some more debugging before pulling this over to the master
branch.