Added leaf counter