Some general errors were corrected.

The script is tested and some general PHP parse errors and some logic
errors are corrected. Once the tests are completed and the documentation
changed the changes will be merged to the the master branch.