Improved command parsing