Ok-ed parts from patch by zhentan feng.