major code reorganization