More robust clipboard handling