Optimize weak hash map usage