Cleaned up redundancies and added comments.