some refactorings/improvements