Fix communication of errors

Use *string instead of error to decode into.
Fix condition in finding first error.
Return library errors instead of panic.