Some bugs found on the ror31 branch which apply equally here. (from jul 27)