I've had A/B solved by just schottky rectifier and low enough current optocoupler, but damn ,didn't knew there is even more to that mess