Some refactoring, fix crash on resume, switch back to front screen on death.