cleanup debug mode and copy port id