Better error handling. Fixes Issue #4