Cleaned up command processing and logging.