All problems fixed and it's working 100%. In the previous code, I was checking if a ident was a constant by checking if it was equal to 'constant', when I should have been checking if it was equal to 'const'. That's the kind of error that makes me want to destroy entire villages.