Added a new, event-based API. Work in progress at present.