Improve and simplify command parsing.