Update gameengine.py :
switch_state() now correctly assigns self.states[-1].engine = self