Code cleanup.
Fixed port order bug.