Fixes and optimizations. hitmap_discover is fully functional now.