small refactorings and improvements