Fixed bugs caused by PHP inconsistencies