Fix port detection