Defensive coding. Fixes #86