refactoring and other changes, cf. diff