Imported from https://github.com/rktamplayo/MCFA