Basic fixes for various breakages with modern versions of PHP5