Added SASA code, mostly adapted from msmbuilder.