some refactorings and fixes/ additional additions