Modified for compatibility with CMSMS 2.0.