Refactor command dispatch and parameter handling by @kaos