Feature/20 improve error handling

Improvement for #21 & #23.