Print maximum memory consumed during the run.
Minor performance tweaks.