Updated flatten.js