Partial merge with Kevin's code for testing