Fixed re-allocation bug