easy fixes ({}, new FlowDef, toSet)
get rid of 'writeFromAndGetTail' and instead just get the last pipe in the list
fix upstream heads filter, remove unnecessary import