Simplify code and add maximal duality proof