add flatten and fix unflatten
new library name