Major updates to the JS code