Fix for issue #18.

Also contains an unrelated commit adding some missing semicolons. It is valid JavaScript to not have them, but in practice can cause problems with browser portability.