Updated to handle multiple calls on one page, and other minor details