Clean up Tree code