Refactored entity state wire into a simple function.
Cleanups.