Ramified theory of types