Add doc comments to all relevant functions.

There is still no doc comments for the modules yet though.