Fixing a problem in flatten.