Rewrite: use callbacks and simpler events