factor out tree-to-map conversion, update mem pl