change the slow simplify(...) function to faster factor() function,
also add some comment.