Do id freeing on rollback
Merge pull request #3020 from rickardoberg/rollbackhandling

[master] Do id freeing on rollback