Further refactoring of the code.