Added comments and cleanded up code format.