Global code refortmat and cleanup