Fix an edge case that caused the bug in #475 to sometimes reoccur
Merge pull request #525 from leonidg/leonidg-misc

Fix an edge case that caused the bug in #475 to sometimes reoccur