smarter branching, updated for mtwrapper2