More memory logging, small adjustments, new tests.