Make APPLY secure against RETURN/redo (#1949)

See http://issue.cc/r3/1949 for details.