Fix JS build problems. Closes #288