Do some refactoring of the code structure.

Death to the M*C long live the notaries!