Fixed JavaScript errors