More fixes.
More refactoring.