Refactoring tree loading