Added basics for counting (possibly wrong) and took care of a problem when itrees were empty