Move stacking to metadata and don't modify data.

Close #868.
Why this change?