Improve cmd parameter parsing and handling