Improved filename handling