Improve command parsing logic.