minor refactorings; docs improved