First pass at integrating Vivek's code from 3.1.1