Mass simplified code

* Added lib
* Added documentation
* removed excess whitespace
* removed excess ()s
* Added multiline comments