Refactor to use ActorLocalRef in internals