Total refactoring to be able to call it from Excel on Mac.