Finalize functions and comments.

Included tests run in comments.