Fixes for php related weirdness encountered while reading code

Couple bugs, rest just ickyness