Bugfix: program crashed if a port was opened twice.
This was caused by the recent callback rewrite.