Updated for PHP5.4/OOP