Implements critical bug fix from MwLibrary2.

Can compile in release mode.