General cleanup and add some comments.