some php bug fixes