Updated to support PHP versions below 5.4.0.