Made code compatible with PHP5.3.