fixes to some memory overlap issues with append()