Complete rewrite of chr for version 2.0.0