More refactoring; also added index vector implementation.