Sharing memory between modes to reduce memory use. Still untested.