Add documentation.
some cleanup in general.