Correcting messages bugs and improving Cost/Equivalence code