some code refactorings and additions