Slow-Motion and Speed Boost - Jerky Movement Once Energy is Finished

I have my character moving on the y and x in a 2D game, my character is currently just a cube for prototyping reasons.

I have a sprint effect and a slow-motion effect, these are both activated by a button press, both last for a certain amount of time and then get regenerated for reuse.

I have got the general setup to a good level but when my slow-motion or sprint energy stores run out the movement does not entirely go back to normal if you don’t release the buttons, slow-motion and sprint still has a slight effect on the characters movement.

Would be very grateful if someone could point me in the right direction:

My code is a bit messy so apologies!

public var xspeed : float = 24; 
public var yspeed : float = 24; 
var x : float; 
var y : float;
var slowMotionBurnSpeed : float;
var haveSlowMotion : boolean;
var slowMotionAmount : float;
var slowMotionRegenRate : float;
var slowMotionMax : float;
var slowMotionMin : float;
var sprintBurnSpeed : float;
var havesprint : boolean;
var sprintAmount : float;
var sprintRegenRate : float;
var sprintMax : float;
var sprintMin : float;
public var sprintTex : Texture;

function Start ()
{
		haveSlowMotion = true;
		havesprint = true;
}

function Update () { 

// *********** Sprint Button

if ((Input.GetKey ("escape")) && (sprintAmount > sprintMin))

{

xspeed = 50;
yspeed = 50;
sprintAmount -= (sprintBurnSpeed*Time.deltaTime);


}

else 

{
xspeed = 24;
yspeed = 24;
}



// *********** General Movement 

x = Input.GetAxis("Horizontal") * xspeed * Time.deltaTime; 
y = Input.GetAxis("Vertical") * yspeed * Time.deltaTime; 
transform.Translate(x, y, 0); 


// *********** SLow Motion 

if (haveSlowMotion)

{


	if (Input.GetKey ("space")) // Slow Motion
	
			{
			
			if (slowMotionAmount > slowMotionMin)
				{
				Time.timeScale=0.15; 
				slowMotionAmount -= (slowMotionBurnSpeed*Time.deltaTime); 
				}	

		// Ran out of slowMotion charge
	else 
		{
			slowMotionAmount = 0;
			haveSlowMotion = false;
			Time.timeScale = 1;
		}
		
}
}
	
//******** Returning out of slowmotion
	
if (Input.GetKeyUp("space"))

	{
	
	
	Time.timeScale = 1;
	
	}

//******* power ups and true and false

if (slowMotionAmount <= (slowMotionMax))
		
	{
	slowMotionAmount += (slowMotionRegenRate);
	}
	
if (slowMotionAmount >= (slowMotionMin))
	{
	haveSlowMotion = true;
	}	
	
if (sprintAmount <= (sprintMax))
		
	{
	sprintAmount += (sprintRegenRate*Time.deltaTime);
	}
	
if (sprintAmount >= (sprintMin))
	{
	haveSlowMotion = true;
	}		


}

Increase the sprintMin and slowMotionMin amounts so that you don’t allow for them if the player has 0.01 energy out of 100. This causes the jerkiness in movements. Force the player to regen a set amount before allowing the use again. A lot of big games do this too.