This is a patch that modifies the insert key functionality. In stock blender when a user inserts a keyframe in the middle of an fcurve the fcurve will be distorted heavily instead of being placed right on the fcurve. The way this was resolved was by relying on De Castlejau's Algorithm for bezier curve splitting.
The end result is a curve that has a new keyframe in the middle of the fcurve but maintaining the shape.
I have also created functionality that allows for the fcurve to be the same shape when deleting a keyframe in the middle of the curve.