whole bunch of fixes. changed event handling.