Ensure that new objects are inserted in sequence. Fixes out of bounds errors.

I'm not convinced that a similar fix shouldn't apply to deletes as well, but this fixes my immediate crashes.