Fix subtle bug in getOutputLinkIndex() (we are using the wrong link counter)