also use factory for document creation
+added basic formula
+small fixes
Merge origin/master