Refactored setup code for creating a new stack. Refactored menu opening and closing code.