basic code reorganization; no feature changes