Improved misc JS errors after checking with JSHint