minor backports (more for consistency but php warning fixes)