Added more intelligent port selection and routing inside parentBoxes.