1. introduce application interface

2. change to event-based control flow