1. Centralise the logic for getting the filename for a DIE.
2. Use the form of logic suggested by Philippe Ombredanne (thanks!).