Restructured main.c.