cleanup variables

fixed flatten.
added test for failure conditions. failed postprocessing allowed only on extract fail.

Fully tested on Win7.