Fix invariant violation
Merge pull request #329 from krazemon/violation

Fix invariant violation