Finished chapter; TODO: tests