Add APIv2 for new UI, and better API AJAX handling