huge performance optimization for larger maps - caching max id