fixing crashing bugs when recording, switching away and switching back again