Fix permissions on some directories and create missing directories.