Added function prototypes and removed unused code