Extract interfaces for comparator and factory

I think, the lib is little closed. In my opinion extract interfaces should help to reuse in my code.