More robust wandering behavior. Entity improvements.
(cherry picked from commit f46f72b)