FULLPIPE: Split out MGM code into separate file