-split factory into separate components
-more tests and fixes