Fixed ajax bugs