Reorganization of whole code