implicit declaration and undefined reference errors removed.