Changed the formatting and added some comments.