Rewrites everything so as to loop only once over the args.