Optimized file path generation, fixed issue #1