Made port generation smarter.