Updated to work with the latest PHP (Tested on PHP 5.6 using xampp)