Bago fix utils docs and affine

This is just a rebase of #352 on top of the current master, to facilitate the merge.