Updated with local copies of gridx and agsjs