Add support for modifying entity inside handler

$this is now bound by reference, so things like $array->pop() can
work properly.