More refactoring, but doesn't work.