Re-organize code:
- Put related parameters and variables together in structs, and
- Put code for initializing memory to functions on structs.
- Report memory information for debugging
minor changes
...