Minor tweaking of main.c, foundation is nearly stable