Add GNU header to main C file

also some code reformatting to make it easier to read