Hopefully done refactoring.