Fix dirname() being called twice.  Closes: #316.