better OPF detection plus other improvements