refactoring, split functions from pcn.
tolerance
started mlp