First integrals of nonholonomic systems and their generators