Cleanup CSM code