Fixed some out of bounds errors.