correctly renumber MI when copy-paste bug #10192
use sizeof instead of numbers
history.c: use dynamic size for db request
Merge pull request #732 from AlicVB/bug_10192

correctly renumber MI when copy-paste bug #10192