Data assignment in Data Structure causes loss of data

The behaviour where adding variables solves the problem might indicate memory issues. Seeing signs of the use of String (capital S) in your code might explain that.

Please post your full code; if too big, attach the ino file to a post.