Adding common code from BitCare