Creates global variables; fixes back button