I have a tome for your perusal. It is one solution to the 141 errors that HGB sometimes throws.
It is not high priority.
Page 1 explains the general scenario and ideas that I used to solve the 141 error codes
Page 2-5 show the modified code in the various functions throughout HGB
Page 6-12 shows the include <TradeContext.mqh> that I have incorporated.
Perhaps some of this might be useful.
(I also use this in HGBB, but that is for later discussion.)
Cheers and enjoy the weekend!