Sanity checks and code clearing.