Fixed multiple JS issues.

Fixes #155.