Optimized to use kspace code only if chgflag.