Fixed port selection with custom connections.
Fixed performance issue.

Also fixed bug and cleaned up code in CR3.js
Merge branch 'autorouter_port'