Added comments and updated documentation