refactored heatmap and coordinate handling.