Fix for #124. Not bounds checking the array apparently causes some problems.