First draft of a solution to the assignment.