Ajax tweaks and bug fixes