Cleaned up command-processor, removed duplicate code