Two more solutions and some refactoring.