Heavy refactoringm.