Add some more docstrings; Move some generic code in utils module; "Privatize" some internal functions.
Bit more cleanup.