Improve handling of remote files