Adding threading to CCM code (CURRENTLY DOES NOT COMPILE)