Generic houskeeping

Continuing migration to generic collections. Also did some minor performance tweaks, removed unused imports etc.