Added some directory checks