Use event system

Fixes #130