idirname had some bugs. Eliminated similar potential errors here as well (i.e. added quotes where needed).