Add fun to compute opt43; split cm:handle_cast into smaller functions