Fix invariant violation error with unique key
Merge pull request #147 from krazemon/invarianterror

Fix invariant violation error with unique key