Cleaned up command processing.