Better error handling

please tag as 0.16