Move setup task to bottom of definition.
Fix dangerous usage of invoke.