Correct balance of BeginContext/EndContext.