Minor refactoring of SWORD diagnostic script.