refactorings concerning memory management. facilities for logging result