Added lots of logic and stubs to main.c