Re-factored patch to work with PHP < 5.4.