Some reorganization of the code.