All functions tested, need a couple more. Cleaned up main.c.