Cleaned up purity-gen code, added state tooltip functionality for purity plotting function