Move Peg to earlier stage.

Add rule optimization.