Minor bug fix

> Fixed bug on setting position equal to the length;

The length is not the same as the total capacity, so the previous code
was wrong.
The current one is a tad bit slower generally but is correct.