Some painful refactoring was done