Fixes from previous commit

Fixed off-by-one error and include requested index in error message.