refactor vertex_cache to use unique_ptr's and less copying