Spacing change between the gradient view and the color editor view.
Make sure the gradient doesn't change in the middle of an edit operation.  This would result in unexpected behavior.  Also, when setting a new gradient, try to keep the selected peg index consistent.