findBestBeta and optimizeTree now take root as the last argument.
Needs to be tested though.
I tested with 8 classes and root always set to K+1. Seems to be working fine