Refactored a bit of stuff in separate functions
Made command execution more logical (execute immediately, switch between normal control and command execution without problem)