Silence warnings about not looking at return values, and make things
a little more robust, by checking return values :)

Not tested on hardware yet. Let me know if there are any issues.