Added some comments and added function prototypes.