Fixing memory leaks when appending items to array properties