Switch to 16-bit indices and some cleanup