bugfix in entity scope correction code.