Minor validation fixes, and some php5 fixes