Some bugs resolved in good minus bad analysis. Invert region script is added.