final CTM lib integrated + small changes