Take the feature's weight into account

See comments in #1882