What factors led to changes in the code of chivalry throughout its history?