move logexpsum to useless.math, move out build_instance