Seperate main function to main.c

Fix typos + cleanup