What's the deal with $gettok(%k,1-1,44) etc..etc...? You could do something as:
tokenize 44 %k if ($1) { if ($2) { if ($3) { if ($4) { ...
There is no custom identifier nor alias called $hkgath found everywhere in the code. I'm not sure what that is used in the first place.