Gave up on using flush and close generics; added some index-related helper functions