Cleanup to match style guidelines

Cleanup, mostly adding comments, also renaming Python API functions.