fix the way branches are worked out and also data fixes