Cleaned up the flatten implementation details to be easier to understand.
Cleaned up the flatten implementation details to be easier to understand.

robertmaynard/Sandbox,robertmaynard/Sandbox,robertmaynard/Sandbox,robertmaynard/Sandbox