* added principal info cache * updated code based on the PR comments * updated implementation of deduplicate() * minor changes * [K, T] -> [K, V]