First cut of the completed code.