Extracted from libcx.