Fix error with negative array bounds in some traversal utils.