Added better directory creation mechanism