Imported from https://github.com/bingmann/cobs