ideas for optimization

To consider for vers.6: have obtaining max1 and max2 as separate functions with op-amp requirement checking inside