Improve performace of TLCustomObjectSerializer.

Serialization performance of TLCustomObjectSerializer was improved by
caching all possible things.
Small refactoring of TLRigFacts.