First/Secondary index methods + refactor of TreeDB class.