Clean up code, add comments.