Refactored some more and cleaned up constructor by moving out stuff to own functions.