fixed bug with unflattening deep structures