I'm not sure sizeof works for array length determination in C, just be safe.  Also fix a couple smaller issues.