Some refactoring of code, about to change command structure.