domain: add advanced state sharing

Using some more advanced state sharing to speed up domains.

This will now only check the domain object if actively in a domain. Also added a quicker way to get the domain object.

I feel like there should be a way to generic-ify the way this state sharing is going on.