Improved style, added comments.