Added code to process and clean up trees before and after running through R