Fixing improper error handling. Fixes #6.