Fixes for php 5.2.x