some general refactorings to handle remote files