Moving thinning to C