reorganized legacy code