Added extern to the function prototypes
Made some functions static