Clean-up multi-instance in created or updated style.

We really want to have the multi_priority starting from 0 and increasing
one by one for every multi-instance module.
Clean-up multi-instance after pasting history from another image.

We really want to have the multi_priority starting from 0 and increasing
one by one for every multi-instance history items just pasted from
another image.
Merge branches 'style-multi-instance' and 'history-multi-instance'

* style-multi-instance:
  Clean-up multi-instance in created or updated style.

* history-multi-instance:
  Clean-up multi-instance after pasting history from another image.
Compute offset as MAX(num) instead of COUNT(num).

This is needed as an history stack may not have continuous num values. This
can happen after applying a style or a partial copy/paste. Note MAX(num) is
already used in other places like image.c.
Remove dead code, can always be resurected from Git.
Merge branch 'fix-offset-value'

* fix-offset-value:
  Remove dead code, can always be resurected from Git.
  Compute offset as MAX(num) instead of COUNT(num).