Refactor command handlers
Better error handling