Fixed a bug in setting the ports