Fixed minor dangling bugs, and started improving the branch creation code.
A few more bug fixes around creating a new branch.