Fix branching bugs