Fix a few bugs to do with the buffer being incremented at start of loop

This may cause a conflict with zedthrees bug fixes.