added object flattening for storage. can now store tree-structure objects.