Fixed possible null reference (Issue #196)

Added checks for null hash. Fixes #196