Added comments, fixed bug.