lots of cleanup, but also added basic event notifications