Fixed bugs

* Fixed bugs: #6 #7 #8 #10
* Modified PHPdoc comments
* Refactored