Clean up cmd handling