Added comments and did some cleaning up.