Fix compile error when using debug flag and fix CX detection