Serial fix

Fixes for incorrect errno setting.