Make index cache size configurable. Misc. bug fixes and added new tests.