Added isdir() check before makedirs() call.