Fixed an off-by-one bug in array setvalue indexing
Merge with master