Move port connection logic to domain layer. Part 1 of #32.