General code reorganization