Clean up javascript and make ws work not on localhost