Numerous bugfixes and doc cleanup in remove_affine