all the refactored connection handling code resides in the connection.js file, its a lot more rebost although still might have bugs