Added png exporting, modularised, changed variance function and further documented heatmap.