Fix several incorrect array indices