Improving the speed of array key lookups that use array_key_exists, closes #617