bunch of changes: make design more modular, implement index (partial