Big refactoring, basic design