replace CreateDirA() and mkdir() scattered everywhere by createDir() with some more error checking.