Several changes and fixes in JS