Fix return types
(cherry picked from commit 68cd64855fad8b2d1c2ef79185796c4d13859880)
Do not indirectly modify properties with refcount > 1
Fix #1327