Pulled some updates from Jeff Mesnil's updated code.