Fixed term reference tree behaviour. Removed testcode from custom.js