Add some better result handling and some error handling (with error codes from api docs.)