Move Peg to earlier stage.
Add rule optimization.
Merge pull request #468 from rsdn/PegUpdate

Move Peg to earlier stage.