The stopApplyingState/endStateTransfer code is getting kind of big, how about extracting it in a separate method?