fixes #16 and another bug with ports