Refactored common otr library code