First draft. Unit tests passing.