Big reorganization of code.