alter backend to allow insertion of new stock ids

Some more tweaking is needed, like always use a higher id than max_id at
this time.