Fix number in error message, clean up indexing a bit