Integrates changes and API from Peter Thatcher