Fixed bugs in mechanisms.R