Incorporate Junjie's fixes for moe calculations.