Changed questionable design decision in the original code: field names and fields are now both numbered from 0, rather than from 1 and 0 respectively.
Added some comments, and simplified field name lookups.