Continues refactoring.
Fixes some s.p. Continues refactoring.