Minor tweaks to wait for elements and AJAX events where appropriate