Fix bug using array $baseDirs

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