BUGFIX Make sure array key exists before attempting to access it.