Purity refactor and enhancements upgrade