fixed bugs revealed by ajax tests