Fix #802
Fix #910, 914
Merge pull request #916 from sjinks/issue-802

Deduplicate macros, Fix memleak in PHP < 5.4