Added comments and rearrangements