Major restructuring of the code.