more rewriting and renaming