Major refactoring of the codebase.