Fix port shuffling code.