major refactor and enhancement to heatmap module