Added function prototypes and definitions