Refactor memory-meta.py into something of a library.