Proper globals, better debug for enumerations; fix bad exception