Refactoring of diversity scripts according to #8