Wrap the 'with_ref' closure for safety
Fix seg-fault
Wrap port in an iterable struct