Fixed some ajax bugs