Improved consistency of the phpdoc blocks, other code documentation, code spacing and readability and fixed some typos