Changed out the tcp server to use javascript objects, broke out some functionality to functions. Fixed unique name problem, as well as closing session issue.