Adds more documentation to Python modules.

..and some minor refactoring.

Change-Id: Ibc1d7229ca021d3612baebff68db5e254efd1044