Changed code about ownership of structures.