Completed PA#2. Added comments and cleand up code.