Fix inconsistent definition.
Re-order definitions.
Add piMaybeFlatten.
Update examples.