Add Code contracts. Eliminate some fixmes.