Fix for index lookup in arrays
Add enum check, fixes #3