This fixes the places where we use the result of .keys(), .items(), and .values() that wouldn't work with an iterator to wrap them with list().
(imported from commit 061b1ccc6649acb9a9fc40370282fa34c645afed)