Better error handling.

Suggested by @MichalHaltuf.
Default options are NULL.