Okay... I got bored and made the code slightly more efficient by replacing the array of types with an enum and the hashtable with an array :)