Added debug support
Cleaned up CMB functions