Well right off the bat with out detailed analysis of your code I can see that anyone that is in more then one group is going to unmap and remap a few times.

You may want to consider the SELECT CASE ENDSELECT method.

What version of KiXtart are you using and what client types do you need to support 9x/nt/2k/xp/2k3 ?
What is the domain model NT/AD?