Fix port replacement for empty ports