small changes in reconnecting
removed some unneeded code, fixed incorrect port id determination