Fix a few jslint complaints
Run try/catch block only once

Rather than run through the try/catch block every time we need to
dispatch an event, we run through it once at initialization, and
decide at that time what we need to do on subsequent calls.  This
should be faster.
Merge branch 'master' into gh-pages