Improve targetEntity handling #675