label old applydefine code as defunct (but keep)
reorganize and clean up in do_set, no substantive change