Do you want the modulestore to produce the re-writes? I think that's the only option to get rid of the conditional logic.