Fix JavaScript errors