Added port handling functions to runtime