What were the key factors that contributed to General Lee's loss at the battle of Gettysburg?