Fixed a bug with graphing ports that came in or out of rigs,
and tidied some code.