Almost complete implementation of exp mechanism.