organize code

No changes on the app. Just organize the code by creating new C files, reducing the size of main.c and making easier to navigate through the code.