Clean up and add some comments.