Fix port number discovery