PrenexTree flattening.
Simplify rebuild.
Fix some warnings.