Now counts the local input and outputs by order of appearence rather
than by port number - it therfore handles ports with bicausality correctely.