Solves Problem 3, improves Problem 8.