Port of changes to primitives class Capsule.