Memory optimizations and supporting code for libmist changes.
Minor memory use optimization.