Refactored tree loading