Fixes bug with finding a free port.