added checks for cases for releasing cpu and changed globals