Replace hex2bin with pack to make it work on PHP-5.3
Fix run time issues for PHP-5.3