Some precautions added to prevent possible crash reported by Emily on 5th of September.
Crash possible only when internal data are inconsistent.