Cleaned up code for problem 5 and finished 6 and 7