Fix a bug where an object was referenced after it was released.
Merge branch 'master' into imageRep