JS nested closures

This addresses one of the major problems we have with our server side chat code. I hope to avoid it in the future.