Cleanup and add some comments.