reorganized type definition & internal function impl.