Fix Undefined behavior

An array subscript is out of range (C99p6.5.6).
Fix minor annoyances.