replaced factors computation by precomputed values, added kernel for
binary mode