Code improvements

- fix php incompatibility issue with older (still very common) php versions
- add response headers