Check hash in viewer constructor.

Fix #229
Fix #176