explicitly cast index in all insert and remove calls