Javascript fixes, following jshint hints