Don't walk off the end of the array.

Closes #1