massive reorganization of code