Added writeWaitError
Added various size consistency checks.