Improve branch history by checking for valid branch format first