Refactor error handling code.
Relase 0.2.1.