Flattening and unflattening code paths in place.