Small optimizations: don't use Linked versions of HashMap / HashSet and use sensible initial sizes