WIP: refactor some code in forest.fit