private void ApplyAngularMomentum()
 {
     FlightGlobals.ActiveVessel.IgnoreGForces(2);
     if (PreviousBodyName == FlightGlobals.ActiveVessel.mainBody)
     {
         Krakensbane.ResetVelocityFrame(true);
         if ((FlightGlobals.ActiveVessel.orbit.eccentricity >= 1) && (ElipMode == 0)) //For Hyperbolic Orbits. Conserve angular momentum by making orbit.h constant. GMp=h^2, so semi-latus rectum must be constant as well.).
         {
             Speed = Math.Sqrt(FlightGlobals.ActiveVessel.mainBody.gravParameter * ((2 / FlightGlobals.ActiveVessel.orbit.radius) - ((SemiLatusOriginal * FlightGlobals.ActiveVessel.mainBody.gravParameter) / (FlightGlobals.ActiveVessel.orbit.semiMajorAxis * OriginalMomentumSqr))));
             var VelocityOffset = (TravelDirection * Speed);
             FlightGlobals.ActiveVessel.SetWorldVelocity(VelocityOffset);
         }
         if ((FlightGlobals.ActiveVessel.orbit.eccentricity < 1) && (ElipMode == 1))                 // For Elliptical Orbits. Conserve Angular Momentum directly by altering state vectors
         {
             Speed = OriginalSpeed * (OriginalFrameTrueRadius / (FlightGlobals.ActiveVessel.orbit.radius));
             var VelocityOffset = (TravelDirection * Speed);
             FlightGlobals.ActiveVessel.SetWorldVelocity(VelocityOffset);
             if (((FlightGlobals.ActiveVessel.orbit.radius / OriginalFrameTrueRadius) >= 0.85) || ((FlightGlobals.ActiveVessel.orbit.radius / OriginalFrameTrueRadius) <= 1.15))                     // re-set variables when ratio between current ratio and original gets too far from 1
             {
                 OriginalSpeed           = Vector3d.Magnitude(FlightGlobals.ActiveVessel.orbit.GetRelativeVel());
                 OriginalFrameTrueRadius = FlightGlobals.ActiveVessel.orbit.radius;
             }
         }
     }
     if (((FlightGlobals.ActiveVessel.orbit.eccentricity < 1) && (ElipMode == 0)) || ((FlightGlobals.ActiveVessel.orbit.eccentricity > 1) && (ElipMode == 1)) || (PreviousBodyName != FlightGlobals.currentMainBody))
     {
         if (PreviousBodyName != FlightGlobals.ActiveVessel.mainBody)
         {
             SetAMStartStateVars();
         }
     }
 }