Fix command functions being out of scope after creating main