numerical problems if the B matrix contains eps in the demand system
another revision with reshuffling of code segments