arg checking and cleanup