older PHP bug fixes
Merge pull request #4 from dwitzig/master

Loads of bug fixes by @dwitzig