Added Prototypes, Comments, updated formatting

All functions were given a prototype and were reordered in a logical order. New comments were added describing the current portions of code. Changed some internal formatting to keep it consistent throughout the file.