Added most functions for exercise 8.