Error fixes

$path instead of $name, check if $file is set.