Many bug fixes to the named port version + tied up the logic and
supporting comments.