Work on issue #1 ('flat' command)

This is work in progress, needs tests, but basically works.