improvements to memd script