Problem Set 4 -> Q5 and Q6 implementations.