Null safeguards Issue #127

Fix #127