Sophist fix for min repeat group 0

This is a fix for Jaanus to generalise the min repeat group count code for editing existing records as well as new records.

Status: Untested.

When Jaanus has tested, I will fix errors and minify and then it will be ready for merging.