\if\value{iclass}<\...@nameuse{#1class}
These lines should be \ifnum, at the very least. You might also want to terminate them with \relax:
\if\value{iclass}<\...@nameuse{#1class}\relax
I haven't checked the rest of the code for correctness, however :) W -------------------------------------------------- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex