Branching state and a few bug fixes