Rewritten main.