Major code refactoring part 8.