almost fully rewrite module