Small cleaning and commented code.

Documented code, cleaned up some small issues.