Fix to use the name as path if it is omitted
Fix an issue that it left garbage in output