The first thing I did was add a few new global variables, and modify others:

optN, optNsize
(new) This is the number of counters, and the number of digits required to represent the number of counters.
attr_gif, attr_txt
(modified) These are two attributes structures, one for GIF-encoded files and one for text files. I've modified them to be arrays rather than scalars.
(new) This is the attributes structure for the directory itself.

You'll notice that the attributes structures and the OCB remain the same as before; no changes are required there.