Added flatten(Ptree*), renamed some functions.