In several places, there are comments like `TODO: write doc`. Write all the required documentation instead.