Adding cleanup code.
Canonicalizing to shift granularity.