Delaying the tasks for the scheduler appears to work.
Routine object now can be used to generate conveniet routines.
Moved to adding tasks in a batch. Old interface left for compatibility.
Trying to get routine adding tested.
Example routine produces more-or-less the expected behaviour.