Code cleanup in copy mode handling