Massive code rafactoring.