Added comments, Formatted code, Fixed typo

* Added comments
 * Added comments for all functions
 * Compact comments for internal functions
 * Block comments (Eclipse-type) for API-functions
* Formatted code
 * Broke  into several (many in fact) functions for convenience in reading
* Fixed typo
 * Typo
 >  ->