Attempt to set grammar when a file gets renamed

Not sure whether this introduces any memory leaks...