commented code

added two tree-saving functions