Refactored PatternMatching with ClassMethods idiom.
Updated PatternMatching to use Either for return values.