Refactor command parsing stuff