Refactor command dispatch logic; support categories