also add an assert so invalid index access will raise an error in debug mode, without this it was quite easy to access invalid memory without meaning to. no functional change.
also add an assert so invalid index access will raise an error in debug mode, without this it was quite easy to access invalid memory without meaning to. no functional change.