phpdoc added.
Added phpdoc, removed some redundant global parameter.
Added phpdoc first part of the file.