Added _sampleData initialization and check before freeing