Fixed wild and crazy side effect: Could not invoke null object error and dir creation