Cleaning up code for problems 1-2
Solved problem 3