file validation
minor refactorings