Patched up some of the invalid bits.