This is ugly stuff, but I'm standing on the shoulders of giants (by copypastaing it from compileRename() ;-) )