Javascript bugfixes