improved command marshalling and unmarshalling