fixed random class reference that was copied
improved tree logic and added more changes