#1795 Use ArrayList to build collection of keys in removeAll, instead of HashSet

Issue #1795 describes the problem with using HashSet here. Using ArrayList fixes the problem.