Improve filename parsing