Reorganizes code