Can you replace these numbers with a "speaking" constant name?
I think these are same as the var's defined in the type_change function.

Maybe something like an enum:
var magic_numbers = { "PCKGS": 1, "UNSRC": 2 ...}
and then use them with: magic_numbers.PCKGS

Maybe this is a task for the enhancement phase, what do you think?