Fix javascript errors

Fixes some javascript-related issues and errors.