Avoid using NA toID for terminal flowlines.
There are a number of places in the workflow where NA is used for terminal flowlines. I've generally tried to move to using 0 for terminal IDs when they are integer and "" (an empty string) when they are character ids. We should try to move the workflow in that direction.