add some changes at flatten algorithms made by @weblancaster
rebuild with gulp