Changed count leaves to be implementation agnostic