Fixed a bug in branching behaviour that was breaking nested sub branches. Code is a lot cleaner now, too.