Php 5.4 compat

Merged new master into php 5.4 compat