Small optimizations: don't use Linked versions of HashMap / HashSet and use sensible initial sizes
(cherry picked from commit 903150c)