Clean up and added some comments.