Simplify wcor code and fix some bugs