Added a function for finding the length of a forest.
cleaned up the code a bit...