Added better error handling in docToModel. Issue #9