Avoid passing potentially big objects by copy

Change-Id: I66414f4b0754cb1cbaf9019d21ae9993d9a22bbc