Broken up fancy tree code into separate templates