Seems like you could trim off this section:
code:
$KixVersion  = @KIX
$KiXMin = '4.21'
select
case instr($KixVersion,'4.21') $KiXFound='4.21'
case instr($KixVersion,'4.22') $KiXFound='4.22'
case 1 $KiXFound=0
endselect

Replace $KixFound with @Kix
I only saw $KixFound in 2 places below that chunk of code.