Added better error checking for responses from server.
Merge branch 'dev' into test