Fixed up some prototypes and added function definitions.