Better memory simplification and fix a memory leak.