Update the js to apply new data format

Aslo adding Andy's changes