Reorganized and removed old code