Fix bug using array $baseDir

* Corrected issue resulting from array constructor
* Corrected issue resulting from invalid clean-up of references