Changed dependency stuff to factory model