Comment on the try block and appease jslint
Use helper functions to clean up html generation
Use more variables instead of repeating strings
Only regenerate html if emoticons have changed