A02: merge with Haley's latest code