Refactored external file management