Refactor file management to separate class