improve support for memory. WIP.