Move functions into the lib as default tree window handler