Moved client connection code out of index.html