Clean up code and optimize AutoConsoleCommand