Added a bunch of documentation in the sourcecode.