Major code refactoring part 7.