Code refactoring for converting files (especially on windows)