Fix incompatibility issue with PHP < 5.4
Add additional checks for invalid request.
Merge pull request #135 from Gautham/Dev

Fix incompatibility issue with PHP < 5.4