Fix filename parsing. Close #1568