Significant code cleanup and removal of unused files