some refactorings, removal of old code