Refactored AddToAny and TakeFromAny to reuse code.