Updated error detection code.