Further refactoring of code.