Check some errors

Discovered by https://github.com/kisielk/errcheck