Found part of the problem... was using DELTREE instead of DELKEY. I have updated the code above, but I still need to do much more testing before really using it on XP.