Fix bug when no directory object is defined