code cleaning, normalize, and support REE